class State {
    clickSwitchHanlder() {
        throw new Error('子类必须重写父类的 clickSwitchHanlder 方法')
    }

    clickDeleteHanlder() {
        throw new Error('子类必须重写父类的 clickDeleteHanlder 方法')
    }
}

export class SignState extends State {
    constructor(uploadObj) {
        super();
        this.uploadObj = uploadObj;
    }

    clickSwitchHanlder() {
        console.log('扫描中，点击无效...');
    }

    clickDeleteHanlder() {
        console.log('文件正在上传中，不能删除');
    }
}

export class UploadingState extends State {
    constructor(uploadObj) {
        super();
        this.uploadObj = uploadObj;
    }

    clickSwitchHanlder() {
        this.uploadObj.pause();
    }

    clickDeleteHanlder() {
        console.log('文件正在上传中，不能删除');
    }
}

export class PauseState extends State {
    constructor(uploadObj) {
        super();
        this.uploadObj = uploadObj;
    }

    clickSwitchHanlder() {
        this.uploadObj.uploading();
    }

    clickDeleteHanlder() {
        this.uploadObj.del();
    }
}

export class DoneState extends State {
    constructor(uploadObj) {
        super();
        this.uploadObj = uploadObj;
    }

    clickSwitchHanlder() {
        console.log('文件已完成上传，点击无效');
    }

    clickDeleteHanlder() {
        this.uploadObj.del();
    }
}

export class ErrorState extends State {
    constructor(uploadObj) {
        super();
        this.uploadObj = uploadObj;
    }

    clickSwitchHanlder() {
        console.log('文件上传失败，点击无效');
    }

    clickDeleteHanlder() {
        this.uploadObj.del();
    }
}